package cn.mazexal.examapi.services;

import cn.mazexal.examapi.dataware.XmindLogMapper;
import cn.mazexal.examapi.models.converter.XmindLogConverter;
import cn.mazexal.examapi.models.db.XmindLogDO;
import cn.mazexal.examapi.models.qry.ExamBankIdQry;
import cn.mazexal.examapi.models.vo.XmindLogVO;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @author: Mazexal
 * Date: 2025/8/30
 */
@Service
public class ResourceService {
    @Resource
    private XmindLogMapper xmindLogMapper;

    @Resource
    private XmindLogConverter xmindLogConverter;


    public List<XmindLogVO> getXmindLogList(ExamBankIdQry qry) {
        List<XmindLogDO> xmindLogDOList = xmindLogMapper.getXmindLogList(qry.getExamBankId());
        if(CollectionUtils.isEmpty(xmindLogDOList)){
            return Collections.EMPTY_LIST;
        }
        return xmindLogDOList.stream().map(xmindLogConverter::toVO).toList();
    }

}
